<template>
	<view class="mask" @click="closeMask">
		<view class="mask-content">
			<view class="title flex-box">
				<!-- <text :decode="true">{{ title }}</text> -->
				<rich-text :nodes="title"></rich-text>
			</view>
			<slot></slot>
			<view class="handle">
				<view class="cancel" v-if="showCancel" @tap="cancel">{{ leftText }}</view>
				<view class="confirm" @tap="confirm">{{ rightText }}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'myPopup',
	props: {
		showCancel: {
			type: Boolean,
			default: true
		},
		title: {
			type: String,
			default: 'title'
		},
		titleIco: {
			type: String,
			default: ''
		},
		titleIcoColor: {
			type: String,
			default: '#333'
		},
		leftText: {
			type: String,
			default: '取消'
		},
		rightText: {
			type: String,
			default: '确定'
		}
	},
	methods: {
		cancel() {
			this.$emit('cancel');
		},
		confirm() {
			this.$emit('confirm');
		},
		closeMask() {
			this.$emit('closeMask');
		}
	}
};
</script>

<style lang="less" scoped>
@import '@/theme.less';
.mask {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 99;
	width: 100vw;
	height: 100vh;
	background-color: rgba(0, 0, 0, 0.5);
	display: flex;
	justify-content: center;
	align-items: center;
	.mask-content {
		background-color: #ffffff;
		box-sizing: border-box;
		width: 70%;
		border-radius: 20rpx;
		text-align: center;
		font-size: 28rpx;
		overflow: hidden;
		.title {
			padding: 20rpx;
			font-size: 32rpx;
			overflow: hidden;
			border-bottom: 1px dashed #e0e0e0;
			text-overflow: ellipsis;
			white-space: nowrap;
			.icons {
				margin-right: 10rpx;
			}
		}

		.handle {
			margin-top: 15rpx;
			display: flex;
			height: 80rpx;
			line-height: 80rpx;
			background-color: @themeColor;
			font-size: 32rpx;
			color: #fff;
			.cancel {
				flex: 1;
				box-sizing: border-box;
				border-right: 2rpx solid #fff;
			}
			.confirm {
				flex: 1;
			}
		}
	}
}
</style>
